<template>
  <div class="app-container">
<!--  产品信息追溯  -->
    <el-row :gutter="24">
      <!--用户数据-->
      <el-col :span="24" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--          <el-form-item label="订单日期" prop="orderDate">-->
<!--            <el-date-picker v-model="queryParams.orderDate" format="yyyy-MM-dd HH:mm" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"-->
<!--                            :default-time="'01:00:00'" :style="{width: '100%'}" placeholder="请选择订单日期" clearable></el-date-picker>-->
<!--          </el-form-item>-->
          <el-form-item label="订单日期" prop="userName">
            <el-date-picker v-model="queryParams.orderDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                            :style="{width: '100%'}" placeholder="请选择订单日期" clearable></el-date-picker>
          </el-form-item>
          <el-form-item label="生产企业" prop="manufacturer">
            <el-input
              v-model="queryParams.manufacturer"
              placeholder="请输入生产企业名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="医疗机构" prop="hospitalname">
            <el-input
              v-model="queryParams.hospitalname"
              placeholder="请输入医疗机构名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
<!--          <el-table-column type="selection" width="50" align="center" />-->
          <el-table-column label="订单日期" align="center" key="orderDate" prop="orderDate" v-if="columns[0].visible" />
          <el-table-column label="生产企业" align="center" key="manufacturer" prop="manufacturer" v-if="columns[1].visible" />
          <el-table-column label="医疗机构" align="center" key="hospitalname" prop="hospitalname" v-if="columns[2].visible" :show-overflow-tooltip="true" />
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleAuthRole(scope.row)"
                v-hasPermi="['system:user:edit']"
              >明细</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

  </div>
</template>

<script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
import {orderList} from '@/api/flow/produceAndTrans'
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "userBinding",
  dicts: ['sys_normal_disable', 'sys_user_sex'],
  components: { Treeselect },

  data(){
    return{
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单表格数据
      orderList: [],
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/user/importData"
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderDate: "",
        manufacturer: "",
        hospitalname: ""
      },
      // 列信息
      columns: [
        { key: 0, label: `订单日期`, visible: true },
        { key: 1, label: `生产企业`, visible: true },
        { key: 2, label: `医疗机构`, visible: true }
      ]
    }
  },
  created() {
    this.getList();

  },
  methods:{
    /** 查询订单列表 */
    getList() {
      this.loading = true;
      orderList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        // debugger;
          this.orderList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 跳转明细绑定 */
    handleAuthRole: function(row) {
      // console.log('订单数据',row)
      const objOrderId = row.orderId;
      this.$router.push({path:"/flow/courseFrom/couresFromDetail/index/"+row.orderId,query: {orderId: objOrderId}});//跳转+传参(订单id)
    },


  }

}
</script>

<style scoped>

</style>
